﻿#pragma once

#include "CTsmpBag.h"
#include "CIParaWrapper.h"
#include "CTprgInfWrapper.h"
#include "CTickmarkManager.h"
#include "CBuffer10Wrapper.h"
#include "CResInfWrapper.h"
#include "CEventManager.h"
#include "CEParaWrapper.h"
#include "CGrpInfWrapper.h"
#include "CResultCaculator.h"
#include "CConcCaculator.h"

class AnalExecutor
{
public:
    int32_t rawbagOffset;
    int32_t absoluteDrop;
    int32_t evCount;
    int32_t savedRawbagDrop;
    int32_t loopCounter0;
    int32_t loopCounter2;
    int32_t togglerAutoNegative;
    int32_t toggle7;

    ItemValue item8;

    ItemValue item16;

    ItemValue item24;

    CTsmpBag *pTsmpBag;                  // +128 x32
    CIParaWrapper *pIParaWrapper;        // +132 x33
    CTprgInfWrapper *pTprgInfWrapper;    // +136 x34
    CResInfWrapper *pResInfWrapper;      // +140 x35
    CTickmarkManager *pCTickmarkManager; // +144 x36
    CBuffer10Wrapper *pBuffer10Wrapper;  // +148 x37
    CEventManager *pEventManager;        // +152 x38
    CResultCaculator *pCaculator;        // +156 x39
    CConcCaculator *pConcCaculator;      // +160 x40
    int32_t *pRawBagBuffer;              // +164 x41
    AnalInfo analInfo;
    // CODE code;                               // +168 x42
    // BYTE errMsg[0x400u];                     // +172 x43
    // int32_t status;                            // +1196 x299

    AnalExecutor();

    void printSelf(char *captionUpper, int32_t deep);

    // sub_1001D6E0
    char *getErrMsg();

    // sub_1000CA73
    AnalExecutor *init(CTsmpBag *pTsmpBag, CIParaWrapper *pIParaWrapper, CTprgInfWrapper *pTprgInfWrapper,
                       CResInfWrapper *pResInfWrapper, CEParaWrapper *pEParaWrapper, CGrpInfWrapper *pGrpInfWrapper,
                       CIdtInfWrapper *pIdtInfWrapper, CStdInfManager *pStdInfManager);

    // sub_1000CE41
    void initData();

    // sub_1000F613
    CResultCaculator *initRawBag(int32_t *pSmpHead);

    // sub_1000CDE7
    void *clearItem8();

    // sub_1000CE05
    void *clearItem16();

    // sub_1000CE23
    void *clearItem24();

    // sub_1001D5F0
    void *close(char flag);

    // sub_1000CD08
    void close();

    // sub_1000CFFE
    int32_t start();

    // sub_1000CF89
    int32_t start_();

    // sub_1000D224
    int32_t stop();

    // sub_1001D680
    CIParaWrapper *setStopTime(float stopTime);

    // sub_1001B470
    int32_t isItem8HsPositive();

    // sub_1001BCA0
    int32_t isType2Lose1D();

    // sub_1000F0C1
    int32_t setItem8AndCalcResult(int32_t flag);

    // sub_1000D016
    int32_t stop_(int32_t idx);

    // sub_1000D24F
    int32_t calcResultW50etc(char flag);

    // sub_1000F6E7
    int32_t handlePrgItemEvent();

    // sub_1001C6C0
    int32_t setConcMetric();

    // sub_1000EF62
    int32_t checkAreaDeviation(TDLLResultListItem *pRes, ItemValue *item, float slope);

    // sub_1000DD0E
    int32_t calcResultAndSetMetric();

    // sub_1000FC95
    int32_t handlePeakStart(float time, int32_t flag);

    // sub_1001C6F0
    char *setError(int32_t flag, char *msg, char *msg1033);

    // sub_1001C740
    char *setError(char *Source);

    // sub_1001C640
    int32_t calcAndSetMetric(int32_t head, int32_t tail, int32_t *pCount);

    // sub_100102CE
    int32_t handlePeakEnd(float time, int32_t flag);

    // sub_10010953
    int32_t handlePeakMoveSplit(float time, int32_t flag);

    // sub_100111A7
    int32_t handlePeakAddSplit(float time, int32_t flag);

    // sub_1001227D
    int32_t handlePeakDelSplit(float time, int32_t flag);

    // sub_10012739
    int32_t handlePeakAddOnlyOne(float timeBegin, float timeEnd, int32_t flag);

    // sub_10013806
    int32_t handlePeakDelete(float timeStart, float timeEnd, int32_t flag);

    // sub_10013D9D
    int32_t handleBaseValley(float timeStart, float timeEnd, int32_t flag);

    // sub_10015A2D
    int32_t handleBaseFrontTangent(float timeStart, float timeEnd, int32_t flag);

    // sub_10014402
    int32_t handleBaseTogether_(float timeStart, float timeEnd, int32_t flag);

    // sub_100153D1
    int32_t handleBaseTailTangent(float timeStart, float timeEnd, int32_t flag);

    // sub_1000DC5F
    CODE execAnal();

    // sub_1000D764
    CODE _execAnal();

    // sub_1000DD54
    int32_t calcAbsoluteDrop();

    // sub_1000D31F
    int32_t setEventWrapperData(int32_t rbIdx);

    // sub_1001B5A0
    int32_t isEventType1(EVENT event);

    // sub_1001B5D0
    int32_t isEventType2(EVENT event);

    // sub_1001B600
    int32_t hasEventType(EVENT event);

    // sub_1001B630
    int32_t checkEmptyEvent(EVENT event);

    // sub_1000DE42
    void doNextAccordingStatus();

    // sub_1000DEA1
    void doNextStatus0();

    // sub_1000E1A3
    void doNextStatus1();

    // sub_1000E4EB
    void doNextStatus2();

    // sub_1000E78A
    void doNextStatus3();

    // sub_1000EEAF
    int32_t checkAndInitCalcUnit();

    // sub_1000EF06
    CBuffer10Wrapper *initCalcUnit();

    // sub_1001B830
    int32_t isBuffer0TimeExceedEx();

    // sub_1001B910
    int32_t isType2WinH10Exceed();

    // sub_1001BA80
    int32_t isType1WinPositive();

    // sub_1001BC50
    int32_t isBaseTailTangentEventCountExceed(int32_t threshold);

    // sub_1001BD00
    int32_t isTailModeDHGreaterThenEventWidth();

    // sub_1000F37A
    int32_t calcItemUsingItem24(int32_t offset);

    // sub_1000F49D
    int32_t calcItemUsingItem16(int32_t offset);

    // sub_1001BEF0
    int32_t isType2Win1D();

    // sub_1001BF50
    int32_t isType1Win();

    // sub_1001C430
    int32_t isType2Win8D();

    // sub_1001C500
    int32_t isType0Win();

    // sub_1000F585
    int32_t calcPeakOrTickmark();

    // sub_1001632B
    int32_t checkPeakAndCalcMetricV1(float beginTime, float endTime, float pkNoise, int32_t flag);

    // sub_10016255
    int32_t checkPeakAndCalcMetricV2(float beginTime, float endTime, float pkWidth, int32_t flag);

    // sub_100160A9
    int32_t checkPeakAndCalcMetricV3(float beginTime, float endTime, int32_t flag);

    // sub_1001617F
    int32_t checkPeakAndCalcMetricV4(float beginTime, float endTime, int32_t flag);

    // sub_1001D860
    int32_t setUkPkFactor(TUkPkFactor *lpUkPkFactor);

    // sub_1001D8C0
    int32_t setIdtTimeOfs(float fTimeOfs);

    // sub_1001D920
    int32_t setYMinUnit(double yMinUnit);

    // sub_1001D990
    int32_t setIdtQualitMode(int32_t nQualitMode, float fTimeWindow);

    // sub_1001DA20
    int32_t setXMinUnitK(double xMinUnitK);

    // sub_1001DA90
    int32_t setMiscellaneous(TMiscellaneous *wParam, int64_t lParam);

    // sub_1001D800
    CTickmarkManager *callbackDraw(int32_t chn);
};